$(function() {
	// Random background
	var kvs = ['kv1', 'kv2', 'kv3', 'kv4', 'kv5', 'kv1', 'kv1', 'kv1', 'kv1', 'kv1', 'kv1'],
		win = $(window),
		body = $(document.body),
		nav = $('nav.navbar.navbar-fixed-top');
	caupmeta = $('.caup-meta'),
		recentFloat = $('#recent-float');
	body.addClass(kvs[Math.floor(Math.random() * kvs.length)]);

	// Billboard
	var billboard = $('#billboard');
	if ($('.toggle-control', billboard).css('display') == 'none') {
		billboard.css('margin-top', win.height() - 70); // - 143
	} else {
		setTimeout(function() {
			$('#billboard').removeClass('opened').addClass('closed');

			var rfmt = Math.floor((win.height() - nav.outerHeight() - caupmeta.outerHeight() - recentFloat.outerHeight()) / 2);
			recentFloat.css({
				'margin-top': rfmt < 5 ? 5 : rfmt,
				'margin-right': -25,
				'visibility': 'visible'
			}).animate({
				'opacity': 1,
				'margin-right': 0
			}, 800);
		}, 1500);
	}
	$('.toggle', billboard).click(function() {
		if (billboard.hasClass('opened')) {
			billboard.removeClass('opened').addClass('closed');
		} else if (billboard.hasClass('closed')) {
			billboard.removeClass('closed').addClass('opened');
		} else {
			billboard.addClass('opened');
		}
	});


	var profswiper = new Swiper('#billboard .proflist-container', {
		width: 80,
		spaceBetween: 10,
		autoplay: 3500,
		setWrapperSize: true,
		loop: true,
		loopedSlides: 3,
		slidesPerView: 'auto',
		prevButton: '#billboard .btn-left',
		nextButton: '#billboard .btn-right'
	});
});